<template>
  <div id="page">
    <Myheader :page="page"></Myheader>
    <!--<myheader></myheader>-->
    <!--<myflow :stepindex=1></myflow>-->
    <div class="page">
      <!--<div class="warpper">-->
      <!--<h1 class="title">2018阳山半程马拉松</h1>-->
      <!--<p class="message">时间: 2018-04-01 08:00</p>-->
      <!--<p class="message">地点: 江苏省 无锡市 惠山区阳山镇</p>-->
      <!--</div>-->

      <!--<group title="" class="weui-cells_form">-->
      <!--<x-input placeholder="请输入报名时填写的证件号码" title="" class="weui-vcode">-->
      <!--<x-button slot="right" type="primary" mini>报名查询</x-button>-->
      <!--</x-input>-->
      <!--</group>-->
      <!--<div id="index">-->
      <!--<div class="index-topf" v-if="this.indexStatus==0">-->
      <!--<h2>{{$t('index.datum')}}</h2>-->
      <!--<group class="top-group">-->
      <!--<x-input class="weui-vcode" v-model="indexNumber" :placeholder="$t('index.enter')" :is-type="isIdNumber">-->
      <!--</x-input>-->
      <!--<x-input placeholder="请填写验证码" v-model="code" class="weui-vcode">-->
      <!--<x-button :disabled='clock' slot="right" type="primary" @click.native="countDown" mini>{{codeMessage}}-->
      <!--</x-button>-->
      <!--</x-input>-->
      <!--<div style="padding-left: 10px;padding-right: 10px;margin-top: 10px;margin-bottom: 10px">-->
      <!--<x-button type="primary" :disabled="buttonFlag" @click.native="indexBind('click')">绑定</x-button>-->
      <!--</div>-->
      <!--</group>-->

      <!--</div>-->
      <!--<div class="index-tops" v-if="this.indexStatus==1">-->
      <!--<h2>{{this.name}}</h2>-->
      <!--<grid :cols="3" class="gridbox">-->
      <!--<grid-item>-->
      <!--<load-more :show-loading="false" :tip="$t('index.gender')" background-color="#fbf9fe"></load-more>-->
      <!--<span class="grid-center">{{this.gender}}</span>-->
      <!--</grid-item>-->

      <!--&lt;!&ndash;有参赛号&ndash;&gt;-->
      <!--<grid-item v-if="bib" @click.native="competingNo" v-model="cn">-->
      <!--<load-more :show-loading="false" :tip="$t('index.bib')" background-color="#fbf9fe"></load-more>-->
      <!--<span v-show="bib" class="grid-center">{{this.bib}}</span>-->
      <!--</grid-item>-->

      <!--&lt;!&ndash;无参赛号&ndash;&gt;-->
      <!--<grid-item @click.native="competingNo" v-model="ce">-->
      <!--<load-more :show-loading="false" tip="状态" background-color="#fbf9fe"></load-more>-->
      <!--<span v-show="!bib" class="grid-center">{{stateMessage}}</span>-->
      <!--</grid-item>-->

      <!--<grid-item @click.native="competitionEvents" v-model="ce">-->
      <!--<load-more :show-loading="false" :tip="$t('index.project')" background-color="#fbf9fe"></load-more>-->
      <!--<span class="grid-center">{{this.project}}</span>-->
      <!--</grid-item>-->
      <!--</grid>-->
      <!--<x-button class='cancel-button' type="primary" mini @click.native="ButtonCancel">{{$t('index.cancel')}}-->
      <!--</x-button>-->
      <!--</div>-->
      <!--<toast v-model="showPositionValue" type="text" :time="800" is-show-mask :text="this.wrongMsg" position="default"-->
      <!--width="20em"></toast>-->
      <!--<toast v-model="noOpenMessage" type="warn">{{$t('index.Noopen')}}</toast>-->
      <!--<actionsheet v-model="cn" :menus="menus1" @on-click-menu="clickActionBib">-->
      <!--<p slot="header" v-html="$t('index.bib')"></p>-->
      <!--</actionsheet>-->

      <!--<actionsheet v-model="ce" :menus="menus2" @on-click-menu="clickActionPro">-->
      <!--<p slot="header" v-html="$t('index.project')"></p>-->
      <!--</actionsheet>-->
      <!--</div>-->

      <divider>赛事信息</divider>
      <form-preview :header-label="raceinfo.name" header-value="" :body-items="list" :footer-buttons="buttons2"></form-preview>
      <br>

      <divider ref="time">报名项目</divider>

      <div class="groupWarp" v-show="!showLoading">
        <group>
          <cell v-for="event in eventList" :key="event.id" :title=event.name link="/disclaimer" :disabled="!getState1(event)" :inline-desc="getState(event)" @click.native="setProject(event.name,event.id,raceid)"></cell>
        </group>
      </div>

    </div>

    <div class="procedure">
      <div class="title">
        <h3 class="top-title" ref="title"></h3>
        <!-- <ul class="weui-media-box__info">
          <li class="weui-media-box__info__meta">来源信息</li>
          <li class="weui-media-box__info__meta" ref="time"></li>
          <li class="weui-media-box__info__meta weui-media-box__info__meta_extra">其他信息</li>
        </ul> -->
        <divider ref="time">{{ruleName}}</divider>
      </div>

      <div class="content" v-html="ruleHtml"></div>
    </div>

    <loading :show='showLoading'></loading>
  </div>
</template>


<script type="text/ecmascript-6">
const countTime = 60; //倒数计时60秒
/* eslint-disable*/
const STARTSTR = "进行中"; //进行中提示
const ENDSTR = "已经结束"; //结束提示
const UNSTARTSTR = "尚未开始"; //尚未开始提示

import Myflow from "@/common/components/myflow.vue";
import {
  debounce,
  Group,
  Cell,
  XInput,
  XButton,
  XTable,
  Divider,
  FormPreview,
  LoadMore,
  Actionsheet,
  Toast,
  Grid,
  GridItem
} from "vux";
import Loading from "@/common/components/loading.vue";
import Myheader from "@/common/components/myheader.vue";

// 获取项目列表
import qs from "qs";
import { axios } from "@/api/axios.js";
import { indexedDB } from "@/api/indexedDB.js";
import { cookie } from "vux";
import mixin from "@/common/js/mixin.js";
//自定义方法
import { dateStringToDateTime } from "@/common/js/main.js";

import { isIdNumber } from "@/common/js/main.js";

export default {
  mixins: [mixin],
  props: ["page", "host"],
  data() {
    return {
      raceinfo: "",
      list: [],
      name: "",
      value: "",
      eventList: [],
      timeDate: "",
      statusType: STARTSTR,
      showLoading: false,
      raceid: "",
      ke: "",
      inviteCode: "",
      ruleHtml: "",
      ruleName: "",
      data: "",
      // key: "wuximarathon",
      // 显示状态
      indexStatus: 0,
      // 证件号
      indexNumber: "",
      raceId: 0,
      name: "",
      //列表显示的参赛号
      bib: "",
      project: "",
      mydata: {},
      gender: "",
      cn: false,
      ce: false,
      type: [],
      items: [],
      // 参赛号数组
      competingnos: [],
      menus1: {},
      menus2: {},
      buttonFlag: true,
      showToast: true,
      showPositionValue: false,
      wrongMsg: "",
      enen: [],
      //raceid的赛事信息
      raceData: [],
      keyValue: [],
      rule: true,
      map: true,
      disclaimer: true,
      notes: true,
      package: true,
      noOpenMessage: false,
      tag: true,
      ruleid: "",
      mapid: "",
      disclaimerid: "",
      notesid: "",
      packageid: "",
      procedureid: "",
      codeMessage: "发送验证码",
      clock: false,
      code: "",
      state: "",
      stateMessage: "",
      buttons2: [
        {
          style: "primary",
          text: "查询报名",
          onButtonClick: name => {
            this.$router.push({
              path: "/bind"
            });
          }
        }
      ]
    };
  },
  created() {
    this.raceId = this.page.raceid;
    this.timeDate = new Date().valueOf();
    //获取indexedDB存在的数据warnMessage
    indexedDB(
      "warnMessage",
      "get",
      this.RACEID,
      "",
      function(a) {
        this.wrongMsg = a;
        if (this.wrongMsg && this.wrongMsg !== "") {
          this.$vux.toast.show({
            text: this.wrongMsg,
            type: "warn"
          });
          indexedDB("warnMessage", "set", this.RACEID, "", function() {});
        }
      }.bind(this)
    );

    //获取赛事信息
    this.raceInfo();

    indexedDB(
      "IDNumber",
      "get",
      this.RACEID,
      "",
      function(a) {
        this.myId = a;
        if (cookie.get("_sid")) {
          this.indexNumber = this.myId;
          this.indexStatus = 1;
          this.indexBind1();
        } else if (this.myId && this.myId !== "") {
          this.indexNumber = this.myId;
          //this.indexStatus = 1;
          // this.indexBind1();
        } else {
          this.indexNumber = this.myId;
        }
      }.bind(this)
    );

    //获取邀请码
    indexedDB("invite", "get", this.RACEID, "", a => {
      if (!!a) {
        this.inviteCode = a.invitationCode;
        this.inviteEventId = a.invitationEventId;
      }
    });

    indexedDB("raceInfo", "get", this.RACEID, "", a => {
      if (!!a) {
        this.raceinfo = a;

        if (this.raceinfo.city == null) {
          this.raceinfo.city = "";
        }
        //console.log(this.raceinfo);
        this.list.push({
          label: "时间",
          value: this.raceinfo.time
        });
        this.list.push({
          label: "地点",
          value: this.raceinfo.city + this.raceinfo.address
        });

        this.ruleID = a.rule;
        this.data = a.time;
        this.inviteCode = a.invitationCode;
        this.inviteEventId = a.invitationEventId;
        this.getRuleHtml(this.ruleID);
      }
    });
    if (this.$route.query.dataType == "show") {
      this.axios
        .post(
          `${window.host}race/events`,
          qs.stringify({
            raceid: this.page.raceid,
            ke: this.page.ke
          })
        )
        .then(response => {
          if (response.data.code == "200") {
            this.eventList = response.data.data;
          }
        });
    } else {
      // 获取赛事列表
      this.axios
        .post(
          `${window.host}race/events`,
          qs.stringify({
            raceid: this.page.raceid,
            ke: this.page.ke
          })
        )
        .then(response => {
          if (response.data.code == "200") {
            this.eventList = response.data.data;
          }
        });
    }
    this.timeDate = new Date().valueOf();
  },
  methods: {
    isIdNumber: function(value) {
      this.buttonFlag = !isIdNumber(value) && this.code != "";
      return {
        valid: isIdNumber(value),
        msg: "请输入正确的证件号"
      };
    },
    countDown() {
      if (this.clock) {
        return;
      }
      if (this.indexNumber == "") {
        return;
      }
      this.sendCode();
      this.clock = true;
      let _this = this;
      this.codeMessage = countTime;
      let countDown = setInterval(function() {
        //console.log(_this.codeMessage)
        if (_this.codeMessage <= 1) {
          _this.codeMessage = "发送验证码";
          _this.clock = false;
          clearInterval(countDown);
          return;
        }
        _this.codeMessage--;
      }, 1000);
    },
    gogogo() {
      location.href = "/";
    },
    sendCode() {
      this.axios
        .post(
          `${window.host}registration/bind`,
          qs.stringify({
            raceid: this.page.raceid,
            idnum: this.indexNumber
          })
        )
        .then(response => {
          if (response.data.code == "200") {
            this.$vux.toast.show({
              text: "短信发送成功"
            });
          } else {
            this.$vux.toast.show({
              text: response.data.msg,
              type: "cancel"
            });
          }
        });
    },
    showNoOpen: function(item) {
      var num = event.target.children[0].children[0].className;
      if (num.indexOf("fa-no") === -1) {
        this.noOpenMessage = false;
        if (item == "我的报名") {
          this.$router.push({
            path: "/list"
          });
        }
        if (item == "我的照片") {
          this.$router.push({
            path: "/photo"
          });
        }
        if (item == "我的成绩") {
          this.$router.push({
            path: "/certificate"
          });
        }

        if (item == "竞赛规程") {
          this.$router.push({
            path: "/procedure",
            query: { id: this.ruleid }
          });
        } else if (item == "报名须知") {
          this.$router.push({
            path: "/procedure",
            query: { id: this.notesid }
          });
        } else if (item == "领物通知") {
          this.$router.push({
            path: "/procedure",
            query: { id: this.packageid }
          });
          // console.log(33);
        } else if (item == "比赛路线") {
          this.$router.push({
            path: "/procedure",
            query: { id: this.mapid }
          });
        }
      } else {
        this.noOpenMessage = true;
      }
    },

    // 查询赛事信息列表
    raceInfo: function() {
      let that = this;
      this.axios
        .post(
          `${window.host}race/show`,
          qs.stringify({
            raceid: this.page.raceid
          })
        )
        .then(response => {
          that.raceData = response.data.data;
          (that.ruleid = that.raceData.rule),
            (that.mapid = that.raceData.map),
            (that.disclaimerid = that.raceData.disclaimer),
            (that.notesid = that.raceData.notes),
            (that.packageid = that.raceData.package),
            //写入indexedDB数据disclaimer,
            indexedDB(
              "disclaimer",
              "set",
              this.RACEID,
              this.raceData.disclaimer,
              function() {}
            );

          for (var key in that.raceData) {
            var value = key;
            that.keyValue.push(value);
          }

          Array.prototype.in_array = function(element) {
            for (var i = 0; i < this.length; i++) {
              if (this[i] == element) {
                return 1;
              }
            }
            return -1;
          };
          if (that.keyValue.in_array("rule") !== -1 && that.raceData["rule"]) {
            this.rule = false; //置灰
          }
          if (that.keyValue.in_array("map") !== -1 && that.raceData["map"]) {
            this.map = false;
          }
          if (
            that.keyValue.in_array("disclaimer") !== -1 &&
            that.raceData["disclaimer"]
          ) {
            this.disclaimer == false;
          }
          if (
            that.keyValue.in_array("notes") !== -1 &&
            that.raceData["notes"]
          ) {
            this.notes = false;
          }
          if (
            that.keyValue.in_array("package") !== -1 &&
            that.raceData["package"]
          ) {
            this.package = false;
          }
        });
    },
    clickActionPro() {},
    //跳转路由
    goRouter(path) {
      if (this.indexStatus == 0) {
        this.$vux.toast.show({
          text: this.$t("index.bandfirst"),
          type: "warn"
        });
      } else {
        this.$router.push(`/${path}`);
      }
    },
    indexBind1: function(a) {
      let _this = this;
      this.axios
        .post(
          `${window.host}registration/fetch`,
          qs.stringify({
            idnum: this.indexNumber,
            raceid: this.raceId
          })
        )
        .then(response => {
          if (response.data.code === "200") {
            if (response.data.data.length == 0) {
              this.$vux.toast.show({
                text: this.$t("index.nofound"),
                type: "warn"
              });
              //删除indexedDB数据IDNumber,
              indexedDB(
                "IDNumber",
                "remove",
                this.RACEID,
                "",
                function(a) {
                  this.indexStatus = 0;
                  this.indexNumber = "";
                }.bind(this)
              );
              return false;
            }
            // 成功则获取数据,得到一个对象
            this.mydata = response.data.data;
            //console.log(this.mydata)

            // console.log(this.mydata)
            // 项目
            // 获取参赛项目,进行遍历

            //临时跳转
            /*   if (!!a && a == 'click') {
             this.$router.push({
             path: "/message",
             });
             }*/
            //临时跳转结束

            this.axios
              .post(
                `${window.host}race/events`,
                qs.stringify({
                  raceid: this.raceId
                })
              )
              .then(response1 => {
                _this.type = [];
                _this.mydata.forEach(function(item, index) {
                  response1.data.data.forEach(function(item1, index1) {
                    if (item.eventid == item1.id) {
                      _this.type.push(item1.name);
                    }
                  });
                });
                _this.items = _this.type;
                _this.project = _this.items[0];
              });

            _this.mydata.forEach((item, index) => {
              //console.warn(item)
              if (!!item.refundid && !!item.invite) {
                var message = "报名成功/邀请码报名";
                this.stateMessage = message;
              } else if (!!item.refundid) {
                //退款的
                this.stateMessage = "有退款";
              } else if (item.state === "normal") {
                this.stateMessage = "报名正常";
              } else if (item.state === "wait") {
                if (!!item.pos) {
                  //候补 有post人数
                  this.stateMessage = `候补中,前边有${item.pos}人`;
                } else {
                  //候补 没有post人数
                  this.stateMessage = `候补中`;
                }
              } else if (item.state == "draw") {
                this.stateMessage = `等待抽签`;
              } else if (item.state === "undraw") {
                this.stateMessage = `未中签(候补代码${item.wait_pos})`;
              } else if (item.state === "audit") {
                this.stateMessage = `审核中`;
              } else if (item.state === "auditfail") {
                this.stateMessage = `审核未通过(${item.refusemsg})`;
              }

              if (!!item.bib) {
                //遍历数据获取每一个参赛号放入competingnos数组中
                _this.competingnos.push(item.bib);
                _this.bib = this.competingnos[0];
              } else {
                //遍历数据获取每一个参赛号放入competingnos数组中
                _this.competingnos.push(item.bib);
                _this.bib = this.competingnos[0];
              }
            });

            this.name = this.mydata[0].name;
            // 证件号
            this.idnum = this.mydata[0].idnum;
            // 性别
            this.gender = this.mydata[0].gender;
            if (this.gender === "male") {
              this.gender = this.$t("index.male");
            } else if (this.gender === "female") {
              this.gender = this.$t("index.female");
            }
            this.indexStatus = 1;
            //写入indexedDB数据IDNumber,
            indexedDB(
              "IDNumber",
              "set",
              this.RACEID,
              this.idnum,
              function() {}
            );
          } else if (response.data.code === 0) {
            this.wrongMsg = response.data.msg;
            this.showPositionValue = true;
          }
        });
    },
    // 点击请求报名查询接口
    indexBind: function(a) {
      let _this = this;
      this.axios
        .post(
          `${window.host}registration/checkbind`,
          qs.stringify({
            idnum: this.indexNumber,
            raceid: this.raceId,
            code: this.code
          })
        )
        .then(response => {
          if (response.data.code === "200") {
            if (response.data.data.length == 0) {
              this.$vux.toast.show({
                text: this.$t("index.nofound"),
                type: "warn"
              });
              //删除indexedDB数据IDNumber,
              indexedDB(
                "IDNumber",
                "remove",
                this.RACEID,
                "",
                function(a) {
                  this.indexStatus = 0;
                  this.indexNumber = "";
                }.bind(this)
              );
              return false;
            }
            // 成功则获取数据,得到一个对象
            this.mydata = response.data.data;

            // console.log(this.mydata)
            // 项目
            // 获取参赛项目,进行遍历

            //临时跳转
            /*   if (!!a && a == 'click') {
             this.$router.push({
             path: "/message",
             });
             }*/
            //临时跳转结束

            this.axios
              .post(
                `${window.host}race/events`,
                qs.stringify({
                  raceid: this.raceId
                })
              )
              .then(response1 => {
                _this.type = [];
                _this.mydata.data.forEach(function(item, index) {
                  response1.data.data.forEach(function(item1, index1) {
                    if (item.eventid == item1.id) {
                      _this.type.push(item1.name);
                    }
                  });
                });
                _this.items = _this.type;
                _this.project = _this.items[0];
              });

            _this.mydata.data.forEach((item, index) => {
              //遍历数据获取每一个参赛号放入competingnos数组中
              if (!!item.refundid && !!item.invite) {
                var message = "报名成功/邀请码报名";
                this.stateMessage = message;
              } else if (!!item.refundid) {
                //退款的
                this.stateMessage = "有退款";
              } else if (item.state === "normal") {
                this.stateMessage = "报名正常";
              } else if (item.state === "wait") {
                if (!!item.pos) {
                  //候补 有post人数
                  this.stateMessage = `候补中,前边有${item.pos}人`;
                } else {
                  //候补 没有post人数
                  this.stateMessage = `候补中`;
                }
              } else if (item.state == "draw") {
                this.stateMessage = `等待抽签`;
              } else if (item.state === "undraw") {
                this.stateMessage = `未中签(候补代码${item.wait_pos})`;
              } else if (item.state === "audit") {
                this.stateMessage = `审核中`;
              } else if (item.state === "auditfail") {
                this.stateMessage = `审核未通过(${item.refusemsg})`;
              }

              if (!!item.bib) {
                //遍历数据获取每一个参赛号放入competingnos数组中
                _this.competingnos.push(item.bib);
                _this.bib = this.competingnos[0];
              } else {
                //遍历数据获取每一个参赛号放入competingnos数组中
                _this.competingnos.push(item.bib);
                _this.bib = this.competingnos[0];
              }
            });

            this.name = this.mydata.data[0].name;

            this._sid = this.mydata._sid;
            // 证件号
            this.idnum = this.mydata.data[0].idnum;
            // 性别
            this.gender = this.mydata.data[0].gender;
            if (this.gender === "male") {
              this.gender = this.$t("index.male");
            } else if (this.gender === "female") {
              this.gender = this.$t("index.female");
            }

            //console.log(this.idnum)
            this.indexStatus = 1;
            //写入indexedDB数据IDNumber,
            indexedDB(
              "IDNumber",
              "set",
              this.RACEID,
              this.idnum,
              function() {}
            );

            indexedDB("_sid", "set", this.RACEID, this._sid, function() {});

            cookie.set("_sid", this._sid);
          } else if (response.data.code === 0) {
            this.wrongMsg = response.data.msg;
            this.showPositionValue = true;
          }
        });
    },
    // 取消绑定
    ButtonCancel: function() {
      //删除indexedDB数据IDNumber,
      indexedDB(
        "IDNumber",
        "remove",
        this.RACEID,
        "",
        function(a) {
          this.indexStatus = 0;
          this.indexNumber = "";
          cookie.remove("_sid");
        }.bind(this)
      );
    },
    //参赛号的弹框列表
    competingNo: function() {
      // this.competingnos=["1","2"]
      // console.log(this.competingnos);
      this.cn = true;
      for (var i = 0; i < this.competingnos.length; i++) {
        this.menus1[i] = this.competingnos[i];
      }
    },
    //参赛项目弹框列表
    competitionEvents: function() {
      this.ce = true;
      //console.log('---')
      //console.log(this.items)
      for (var i = 0; i < this.items.length; i++) {
        this.menus2[i] = this.items[i];
      }
    },

    // 点击弹窗数据，替换列表数据
    clickActionBib(key, item) {
      this.bib = item;
    },
    clickActionPro(key, item) {
      this.project = item;
      //console.log(this.mydata[key].eventid)
      this.$router.push({
        path: "/message",
        query: { eventid: this.mydata[key].eventid }
      });
    },
    getRuleHtml(id) {
      this.axios
        .post(
          `${window.host}page/query`,
          qs.stringify({
            id: id
          })
        )
        .then(response => {
          if ((response.data.code = 200)) {
            this.ruleName = response.data.data.name;
            this.ruleHtml = response.data.data.content;
          } else {
          }
        });
    },
    // 设置报名信息
    setProject(projectName, id, raceid) {
      //写入project,
      indexedDB("project", "set", this.RACEID, projectName, function(a) {});
      indexedDB("eventId", "set", this.RACEID, id, function() {});
    },
    getState(a) {
      let startDate = dateStringToDateTime(a.reg_begin) || null;
      let endDate = dateStringToDateTime(a.reg_end) || null;
      if (
        typeof this.inviteCode !== "undefined" &&
        this.inviteEventId == a.id
      ) {
        return "报名中(正在使用邀请码报名)";
      }

      if (!a.reg_begin && !a.reg_end) {
        //没有开始时间 没有结束时间  不设置限制
        if (a.state == "audit") {
          return "报名中，需要审核";
        } else if (a.state == "draw") {
          return "报名中，需要抽签";
        } else if (a.state == "normal") {
          if (a.remain <= 0) {
            if (a.allow_wait == 0) {
              return "已经报满了";
            } else if ((a.allow_wait = 1)) {
              return "候补中，有 " + a.wait_count + " 人在候补";
            }
          } else {
            return "报名中";
          }
        }

        return STARTSTR;
      } else if (!a.reg_begin && a.reg_end) {
        //只有结束时间
        if (this.timeDate >= endDate) {
          //大于结束时间 返回已经结束
          return ENDSTR;
        } else {
          //小于结束时间 返回进行中
          if (a.state == "audit") {
            return "报名中，需要审核";
          } else if (a.state == "draw") {
            return "报名中，需要抽签";
          } else if (a.state == "normal") {
            if (a.remain <= 0) {
              if (a.allow_wait == 0) {
                return "已经报满了";
              } else if ((a.allow_wait = 1)) {
                return "候补中，有 " + a.wait_count + " 人在候补";
              }
            } else {
              return "报名中";
            }
          }

          return STARTSTR;
        }
      } else if (a.reg_begin && !a.reg_end) {
        //只有开始时间
        if (this.timeDate >= startDate) {
          //大于开始时间 返回进行中
          if (a.state == "audit") {
            return "报名中，需要审核";
          } else if (a.state == "draw") {
            return "报名中，需要抽签";
          } else if (a.state == "normal") {
            if (a.remain <= 0) {
              if (a.allow_wait == 0) {
                return "已经报满了";
              } else if ((a.allow_wait = 1)) {
                return "候补中，有 " + a.wait_count + " 人在候补";
              }
            } else {
              return "报名中";
            }
          }

          return STARTSTR;
        } else {
          //小于开始时间 返回还未开始
          return UNSTARTSTR;
        }
      } else if (a.reg_begin && a.reg_end) {
        //正常状态，有开始和结束时间
        if (this.timeDate >= endDate) {
          return ENDSTR;
        } else if (this.timeDate <= startDate) {
          return UNSTARTSTR;
        }
      }
    },
    getState1(a) {
      if (
        typeof this.inviteCode !== "undefined" &&
        this.inviteEventId == a.id
      ) {
        return true;
      } else if (a.reg_able) {
        return true;
      } else {
        return false;
      }
    }
  },
  components: {
    Myflow,
    Group,
    Cell,
    Loading,
    Myheader,
    XInput,
    XButton,
    XTable,
    Divider,
    FormPreview,
    debounce,
    LoadMore,
    Actionsheet,
    Toast,
    Grid,
    GridItem
  }
};
</script>

<!-- Add "scoped" attribute to limit CSS to this component only -->
<style lang="less" rel="stylesheet/less">
#page .page {
  .title {
    font-size: 20px;
    line-height: 2;
  }
  .message {
    line-height: 1;
  }
}

#page .warpper {
  padding: 10px;
}

.procedure {
  padding: 10px;
}

.procedure .title {
  margin: 10px;
  width: auto;
}

.procedure .title .top-title {
  text-align: center;
  font-weight: 400;
  // font-size: 17px;
  width: auto;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  word-wrap: normal;
  word-wrap: break-word;
  word-break: break-all;
}

.procedure .weui-media-box__info {
  margin-top: 15px;
  padding-bottom: 5px;
  font-size: 13px;
  color: #745e5e;
  line-height: 1em;
  list-style: none;
  overflow: hidden;
}

.weui-media-box__info__meta_extra {
  padding-left: 1em;
  border-left: 1px solid #745e5e;
}

.weui-media-box__info__meta {
  float: left;
  padding-right: 1em;
}

.procedure .content {
  margin-bottom: 20px;
  width: 100%;
  height: 100%;
}

.procedure .content p {
  margin: 10px 0 10px;
  white-space: normal;
  color: #666;
  font-size: 13px;
  line-height: 200%;
  // overflow: hidden;
  // text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-box-orient: vertical;
  // -webkit-line-clamp: 2;
  // margin: 8px;
}

.procedure .content span {
  color: #666;
  font-size: 13px;
  line-height: 160%;

  margin: 10px;
}

.procedure .content .imgs {
  width: 100%;
  // height: 100px;
  display: table-cell;
  vertical-align: middle;
  // text-align: center;
  padding: 10px;
}

.procedure .content img {
  width: 100%;
}

//h1标签
.procedure .content {
  color: #666;
  box-sizing: border-box;
  h1 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 36px;
    margin-bottom: 10px;
  }
  h2 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 30px;
    margin-bottom: 10px;
  }
  h3 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 24px;
    margin-bottom: 10px;
  }
  h4 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 18px;
    margin-bottom: 10px;
  }
  h5 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 14px;
    margin-bottom: 10px;
  }
  h6 {
    font-weight: 500;
    line-height: 1.1;
    font-size: 12px;
    margin-bottom: 10px;
  }
  ol,
  ul {
    color: #666;
    display: block;
    list-style-type: decimal;
    -webkit-margin-before: 1em;
    -webkit-margin-after: 1em;
    -webkit-margin-start: 0px;
    -webkit-margin-end: 0px;
    -webkit-padding-start: 40px;
  }
  li {
    display: list-item;
    text-align: -webkit-match-parent;
  }
  button {
    display: inline-block;
    padding: 4px 12px;
    margin-bottom: 0;
    font-size: 14px;
    line-height: 20px;
    text-align: center;
    text-shadow: 0 1px 1px rgba(255, 255, 255, 0.75);
    vertical-align: middle;
    cursor: pointer;
    background-image: linear-gradient(to bottom, #fff, #e6e6e6);
    background-repeat: repeat-x;
    border: 1px solid #ccc;
    border-color: rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.1) rgba(0, 0, 0, 0.25);
    border-bottom-color: #b3b3b3;
    border-radius: 4px;
    box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.2),
      0 1px 2px rgba(0, 0, 0, 0.05);
    &:hover,
    &:focus {
      color: #333;
      text-decoration: none;
      background-position: 0 -15px;
      -webkit-transition: background-position 0.1s linear;
      -moz-transition: background-position 0.1s linear;
      -o-transition: background-position 0.1s linear;
      transition: background-position 0.1s linear;
    }
  }
  a {
    color: #666;
    text-decoration: none;
    line-height: 1.75;
    font-size: 14px;
    &:hover {
      color: #c81623;
    }
    strong {
      font-weight: 700;
    }
  }
}

//表格
// .procedure .content table {
//   word-break:break-all;
//   word-wrap: break-word;
//   margin: 0 auto;
//   width: 100%;
//   line-height: 40px;
//   position: relative;
//   // width: 100%;
//   border-collapse: collapse;
//   background-color: rgb(255, 255, 255);
//   display: table;
//   text-align: center;
//   vertical-align: middle;
// }

// .procedure .content th:nth-of-type(1) {
//   border-top: 1px solid #c7c7c7;
// }

// .procedure .content th {

//   position: relative;
//   border-right: 0;
//   border-bottom: 0;
//   border: 1px solid #c7c7c7;
//   text-align: center;
//   font-weight: 500;
//   display: table-cell;
//   vertical-align: inherit;
// }

// .procedure .content td {
//   text-align: center;
//   border-right: 1px solid #c7c7c7;
// }

// .procedure .content tr {
//   border: 1px solid #c7c7c7;
// }
.procedure table {
  width: 100%;
  max-width: 100%;
  white-space: pre;
  border-spacing: 0;
  border-collapse: collapse;
  word-break: break-all;
  word-wrap: break-word;
}

.procedure table thead {
  display: table-header-group;
  vertical-align: middle;
  border-color: inherit;
}

.procedure .tr {
  display: table-row;
  vertical-align: inherit;
  border-color: inherit;
}

.procedure thead > tr > th {
  border-bottom-width: 2px;
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: top;
  text-align: left;
  font-weight: bold;
  border: 1px solid #ddd;
  // display: table-cell;
}

.procedure tbody {
  display: table-row-group;
  vertical-align: middle;
  border-color: inherit;
}

.procedure tbody > tr > td {
  border: 1px solid #ddd;
  padding: 8px;
  line-height: 1.42857143;
  vertical-align: top;
  border-top: 1px solid #ddd;
}

.procedure tbody > tr > th {
  border: 1px solid #ddd;
  text-align: left;
  padding: 8px;
}

.index-topf h2,
index-tops h2 {
  font-size: 30px;
  margin: 30px 0 30px 10px;
  text-align: center;
  color: #3cc51f;
  margin-top: 0;
}

#index {
  h2 {
    font-size: 30px;
    margin: 30px 0 30px 10px;
    text-align: center;
    color: #3cc51f;
    margin-top: 0;
  }
  // 去除group的margintop
  .top-group {
    width: 100%;
  }
  .index-topf {
    margin-bottom: 100px;
    padding-top: 30px;
    .tips {
      padding: 10px 15px;
    }
  }
  .index-bottom {
    height: 60%;
    // 图标颜色
    .fa {
      color: #3cc51f;
      font-size: 28px;
    }
    .fa-no {
      color: #ddd;
      font-size: 28px;
    }
    .weui-grid__icon {
      margin-bottom: 10px;
      pointer-events: none;
    }
    .weui-grid__label {
      pointer-events: none;
    }
  }
  // 详情页
  .index-tops {
    margin: 30px 0 30px 0;
    margin-top: 0;
    padding-top: 30px;
    .gridbox {
      border-bottom: 1px solid #d9d9d9;
      .weui-grid:after {
        border: none;
      }
    }
    .cancel-button {
      margin-top: 15px;
      display: flex;
    }
    .grid-center {
      display: block;
      text-align: center;
      color: #666;
    }
    .gridbox {
      .weui-grid:before {
        border-right: none;
      }
    }
    // 去除选手信息列表的线
    .weui-loadmore_line .weui-loadmore__tips {
      padding: 0;
    }
  }
}

#page .page .vux-form-preview .weui-form-preview__hd .weui-form-preview__label {
  text-align: left;
  text-align-last: auto;
  line-height: 1;
  margin-right: 0;
}

#app #page .footer {
  display: block;
}
</style>








